import {p} from '../ajax.js'
    var div3 = document.getElementById("iot-div3");
    
p("https://api-hmugo-web.itheima.net/api/public/v1/home/catitems").then((res)=>{
    return res.message;
}).then((message)=>{
    console.log(message);
    //批量添加
    creatAndAppend("img","a",4)
    function creatAndAppend(name1,name2,len) {
        for(var i = 1;i<=len;i++){
            window[name1+i]=document.createElement('img');
            window[name2+i] = document.createElement("a");
            window[name2+i].appendChild(window[name1+i]);
            div3.appendChild(window[name2+i]);
            window[name1+i].src = message[i-1].image_src;
            window[name1+i].style.width ="25%"
            window[name1+i].style.aspectRatio = 1/1;
            window[name1+i].style.marginTop = "3%"
            //window[name+i].style.marginBottom = "5%"
        }
    }
    a1.href = "./分类.html";
})